<extend name="Public:base"/>

<!--侧边导航-->
<block name="aside">
    <include file="Public:aside"/>
</block>

<block name="main">

    <form id="myform" class="form-horizontal" action="{:U('Node/add')}" method="post">
        <div class="form-group">
            <label class="col-sm-2 control-label">分组</label>
            <div class="col-xs-4">
                {:Form::select(array('field'=>'groupid','options'=>$groups,'options_key'=>'id,name','class'=>"form-control"),$groupid)}
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">名称</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" name="name" validate="required:true,en_num:true, minlength:2, maxlength:20" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">标题</label>
            <div class="col-xs-4">
                <input type="text" name="title" class="form-control" validate="required:true,cn_username:true, minlength:2, maxlength:20" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">上级</label>
            <div class="col-xs-4">
                <select class="form-control" name="pid">
                    {$nodes}
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">描述</label>
            <div class="col-xs-4">
                <textarea  id="remark" name="remark" rows="3" cols="40" class="form-control">{$udate['remark']}</textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">状态</label>
            <div class="col-xs-4">
                <input type="radio" name="status" value="1" checked="checked"/>启用
                <input type="radio" name="status" value="0" />禁用
            </div>
        </div>

        <div class="form-actions">
            <input type="submit" value="{:L('dosubmit')}" class="btn btn-sm btn-primary" >
            <input type="reset" value="{:L('cancel')}" class="btn btn-sm btn-primary">
            <input type="hidden" name="forward" value="{$_SERVER['HTTP_REFERER']}" />
        </div>
    </form>

</block>

<block name="script">
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {

                layer.confirm(data.info, {
                    icon:1,
                    btn: ['继续添加','返回列表'] //按钮
                }, function(){
                    window.location.href = "{:U('Node/add')}";
                    return false;
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });

            } else {
                layer.msg(data.info, {icon: 2});
            }

        }
    </script>
</block>